/* eslint valid-jsdoc: "off" */

"use strict";

const urls = require('./url')

/**
 * @param {Egg.EggAppInfo} appInfo app info
 */
module.exports = (appInfo) => {
  /**
   * built-in config
   * @type {Egg.EggAppConfig}
   **/
  const config = (exports = {});

  // use for cookie sign key, should change to your own and keep security
  config.keys = appInfo.name + "_1649232410668_6903";

  // add your middleware config here
  config.middleware = ["errorHandler"];

  // 设置上传文件的限制
  config.multipart = {
    mode: 'file',
    // 表单 Field 文件名长度限制
    fieldNameSize: 100,
    // 表单 Field 内容大小
    fieldSize: '100kb',
    // 表单 Field 最大个数
    fields: 10,

    // 单个文件大小
    fileSize: '10mb',
    // 允许上传的最大文件数
    files: 10,
  };
  // 修改启动地址和端口号
  config.cluster = {
    listen: {
      path: "",
      port: 5862,
      hostname: "localhost",
    },
  };

  // 设置请求地址
  config.urls = urls

  // add your user config here
  const userConfig = {
    // myAppName: 'egg',
  };

  // mysql config
  const mysql = {
    client: {
      //host
      host: "localhost",
      //port
      port: "3306",
      //username
      user: "djl",
      //password
      password: "123456",
      //database
      database: "mall_end",
    },
    //load into app,default is open //加载到应用程序，默认为打开
    app: true,
    //load into agent,default is close //加载到代理中，默认值为“关闭”
    agent: false,
  };

  // jwt 和跨域
  const jwt = {
    secret: "^_^",
    expiresIn: "1h",
  };
  const security = {
    csrf: {
      enable: false,
      ignoreJSON: true,
    },
  };
  const cors = {
    origin: "*",
    allowMethods: ["GET", "POST", "PUT", "DELETE", "PATCH"],
  };

  return {
    ...config,
    ...userConfig,
    mysql,
    jwt,
    security,
    cors,
  };
};
